package cn.yunhe.controller;

import cn.yunhe.entity.Field;
import cn.yunhe.entity.User;
import cn.yunhe.entity.UserQuestionHistory;
import cn.yunhe.pojo.UserQuestionHistoryError;
import cn.yunhe.service.UserQuestionHistoryErrorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
public class UserQuestionHistoryErrorController {
    @Autowired
    @Qualifier("userQuestionHistoryErrorService")
    private UserQuestionHistoryErrorService userQuestionHistoryErrorService;
    @RequestMapping("/getUserQuesHisErr")
    public List<UserQuestionHistoryError> getUserQuesHisErr(HttpSession session, HttpServletRequest request){
        User user = (User) session.getAttribute("Curr_User");
        UserQuestionHistory u = new UserQuestionHistory();
        u.setUserId(user.getUserId());
        int id = Integer.parseInt(request.getParameter("id"));
        //这个是将域的id存到session中去
        session.setAttribute("priafieldId",id);
        Field field1 = new Field();
        field1.setFieldId(id);
        List<UserQuestionHistoryError> userQuestionHistoryErrors =  userQuestionHistoryErrorService.getQuesHError(field1,u);
        return userQuestionHistoryErrors;
    }
    //这个是：学生端：试题练习-》错题练习-》参加练习
}
